﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;

using ShippingManage.Models;
using ShippingManage.ShippingManageServices;
using ShippingManage.DataAccessor.Interfaces;

namespace ShippingManage.Services
{
	public class SyncService
	{
		public void SyncData()
		{
			//check has data need sync

			ShippingManageService service = new ShippingManageService();
		}

		public void SynUserInfo(IMembershipUser obj)
		{
			var member = (ShippingMemberUser)obj;
			var model = new VersionInfoModel();
			var currentVersion = model.Get(DataTypes.User, (Guid)member.ProviderUserKey);
			if (currentVersion == null)
				return;

			var service = new ShippingManageService();
			bool mustSyncResult = false, mustSyncResultSpecific=false;
			service.UserMustSync(currentVersion, out mustSyncResult, out mustSyncResultSpecific);
			if (mustSyncResult)
				service.UserSync(obj);
		}
	}
}
